package com.wontube.smr.remote;

import com.wontube.core.annotation.NoLoginSupport;
import com.wontube.core.pub.servlet.handlers.BasicHandler;
import com.wontube.smr.client.IAPICheckHandler;
import com.wontube.smr.conf.SmrConfig;

/**
 * 冗余client.remote.IAPICheckHandler接口
 * @author tanggf(2012-9-11)
 *
 */
@NoLoginSupport
public class APICheckHandler extends BasicHandler implements IAPICheckHandler {
	//private static final String serverAPIVersion = "1.4";
	private static final String minClientAPIVersion = "1.0";
	
	@Override
	public String getServerAPIVersion() {
		return SmrConfig.SINGLE.getVersion();
	}

	@Override
	public String getMinAPIVersion() {
		return minClientAPIVersion;
	}

	@Override
	public Boolean isCurrentClientSupported() {
		String clientAPIVersion = super.getContext().getSession().getLastAPIVersion();
		boolean isSupported = minClientAPIVersion.compareTo(clientAPIVersion) <= 0;
		
		return isSupported;
	}
}
